-
Notifications
You must be signed in to change notification settings - Fork 14k
Allow syntax extensions to return multiple items, closes #16723 #17236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
79f55c7 to
5f0c2ea
Compare
src/libsyntax/ext/base.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This takes self by value now so this could just be Some(self.items.move_iter().collect())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just Some(self.items)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that MacItems does indeed store a SmallVector this should just return Some(self.items)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes! Updated the PR.
|
cc @sfackler |
|
You might as well remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to have an // ignore-stage1.
5f0c2ea to
36b3079
Compare
|
Thanks for your feedback, I've updated the PR. |
36b3079 to
98d6501
Compare
src/libsyntax/ext/base.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This FIXME can likely be removed now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, thanks. Does it still make sense to implement Clone on SmallVector?
98d6501 to
f694386
Compare
f694386 to
3fc46ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to go in run_pass_fulldeps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that was the problem!
The test should pass now, thanks for your help and patience ;)
3fc46ea to
89b0944
Compare
This is PR is basically the change proposed by @SimonSapin for #16723. I can also extend MacItem, as @huonw suggested, but I'm not sure how that was meant exactly. A comment for MacItem states that it's a convenience type for macros that return a single item. Should I adapt MacItem to contain a SmallVector of items instead of a single item and update the comment?
And I've two questions concerning the patch.
First, I am not sure what's the best way to duplicate the SmallVector holding the items. The way I'm doing it at the moment strikes me as suboptimal (https://github.com/fhahn/rust/compare/issue-16723-multiple-items?expand=1#diff-5100da09ad52c81568562e36ee359343R241). An additional map() call is required, because
iter()returns an iterator to pointers to the elements. Is there a better way? Should I open a ticket and implementclone()forSmallVector?And second, I had problems running the test in the test suite because it complains that there is no name
MacItemsinsyntax::base::extalthough there is. When I compile the file withit works. But I'm not sure which
rustcbinary should be used, e.g. there is on stage1 build inx86_64-unknown-linux-gnu/stage1/bin/rustcand one inx86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/rustc.